<!--合同明细---->
<template>
  <a-modal
    :title="title"
    :width="1600"
    :visible="visible"
    :confirmLoading="confirmLoading"
    @ok="handleOk"
    @cancel="handleCancel"
    cancelText="关闭"
    wrapClassName="ant-modal-cust-warp"
    :bodyStyle="bodyStyle"
    style="top:15%;height: 100%"
  >
    <template slot="footer">
      <a-button key="back" v-if="isReadOnly" @click="handleCancel">
        关闭
      </a-button>
    </template>
    <a-spin :spinning="confirmLoading">
      <a-form :form="form" id="customerModal">
        <a-col :span="24 / 3">
          <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="客户名称">
            <a-input placeholder="请输入客户名称" v-decorator.trim="['customerName', validatorRules.name]" />
          </a-form-item>
        </a-col>
        <a-col :span="24 / 3">
          <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="所属行业">
            <a-input placeholder="请输入所属行业" v-decorator.trim="['industry', validatorRules.prductcode]" />
          </a-form-item>
        </a-col>
        <a-col :span="24 / 3">
          <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="内部合同编码">
            <a-input placeholder="请输入内部编码" v-decorator.trim="['contractCode', validatorRules.prductcode]" />
          </a-form-item>
        </a-col>
        <a-col :span="24 / 3">
          <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="合同编号">
            <a-input placeholder="请输入合同编号" v-decorator.trim="['contractNum', validatorRules.prductcode]" />
          </a-form-item>
        </a-col>
        <a-col :span="24 / 3">
          <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="合同性质">
            <a-select
              v-decorator.trim="['contractType']"
              allowClear
              placeholder="请选择合同性质"
              showSearch
              @change="selectChange"
              optionFilterProp="children"
            >
              <a-select-option v-for="(item, index) in nature" :key="index" :value="item.name">
                {{ item.name }}
              </a-select-option>
            </a-select>
          </a-form-item>
        </a-col>
        <a-col :span="24 / 3">
          <a-form-item v-if="other" :labelCol="labelCol" :wrapperCol="wrapperCol" label="二级目录">
            <a-input placeholder="请输入" v-decorator.trim="['contractSecondType']" />
          </a-form-item>
        </a-col>
        <a-col :span="24 / 3">
          <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="合同总金额">
            <a-input placeholder="请输入合同总金额" v-decorator.trim="['contractAmount', validatorRules.prductcode]" />
          </a-form-item>
        </a-col>
        <a-col :span="24 / 3">
          <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="预警付款方式">
            <a-select
              allowClear
              placeholder="请选择预警付款方式"
              showSearch
              optionFilterProp="children"
              @change="handleChange"
            >
              <a-select-option v-for="(item, index) in mode" :key="index" :value="item.name">
                {{ item.name }}
              </a-select-option>
            </a-select>
          </a-form-item>
        </a-col>
        <a-col :span="24 / 3" v-if="money">
          <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="预警付款金额">
            <!-- <a-input placeholder="请输入预警付款金额" v-decorator.trim="['earlyWarningAmount']" /> -->
            <a-input-number
              style="width:100%;"
              placeholder="请输入预警付款金额"
              v-decorator.trim="['earlyWarningAmount']"
              :min="1"
            />
          </a-form-item>
        </a-col>
        <a-col :span="24 / 3" v-if="percentage">
          <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="付款百分比%">
            <a-input-number
              style="width:100%;"
              placeholder="请输入预警付款百分比"
              v-decorator.trim="['earlyWarningRate']"
              :min="1"
              :max="100"
            />
          </a-form-item>
        </a-col>
        <a-col :span="24 / 3">
          <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="付款条件">
            <a-input placeholder="请输入付款条件" v-decorator.trim="['termOfPayment']" />
          </a-form-item>
        </a-col>
        <a-col :span="24 / 3">
          <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="到期付款预警">
            <a-date-picker
              style="width: 100%"
              v-decorator.trim="['earlyWarningDate']"
              format="YYYY-MM-DD"
              placeholder="请选择付款预警时间"
            />
          </a-form-item>
        </a-col>
        <a-col :span="24 / 3">
          <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="订单套数">
            <a-input placeholder="请输入订单套数" v-decorator.trim="['setOfOrders']" />
          </a-form-item>
        </a-col>
        <a-col :span="24 / 3">
          <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="面积">
            <a-input placeholder="请输入面积" v-decorator.trim="['area']" />
          </a-form-item>
        </a-col>
        <a-col :span="24 / 3">
          <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="贵金属价格">
            <!-- <a-input placeholder="请输入贵金属价格" v-decorator.trim="['preciousMetal']" /> -->
            <a-input-number
              style="width:100%;"
              placeholder="请输入贵金属价格"
              v-decorator.trim="['preciousMetal']"
              :min="1"
            />
          </a-form-item>
        </a-col>
        <a-col :span="24 / 3">
          <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="签约时间">
            <a-date-picker
              style="width: 100%"
              v-decorator.trim="['signedDate', validatorRules.prductcode]"
              format="YYYY-MM-DD"
              placeholder="请选择签约时间"
            />
          </a-form-item>
        </a-col>
        <a-col :span="24 / 3">
          <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="合同进度">
            <a-select
              v-decorator.trim="['contractSchedule']"
              allowClear
              placeholder="请选择合同进度"
              showSearch
              optionFilterProp="children"
            >
              <a-select-option v-for="(item, index) in Progress" :key="index" :value="item.name">
                {{ item.name }}
              </a-select-option>
            </a-select>
          </a-form-item>
        </a-col>
        <a-col :span="24 / 3">
          <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="业务负责人">
            <!-- <a-input
              :disabled="show"
              placeholder="请输入业务负责人"
              v-decorator.trim="['businessLeader', validatorRules.prductcode]"
            /> -->
            <a-select
              :disabled="disable"
              v-decorator.trim="['businessLeader', validatorRules.prductcode]"
              allowClear
              placeholder="选择业务负责人"
              showSearch
              optionFilterProp="children"
            >
              <a-select-option v-for="(item, index) in personList" :key="index" :value="item">
                {{ item }}
              </a-select-option>
            </a-select>
          </a-form-item>
        </a-col>
        <a-col :span="24 / 3">
          <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="上传合同">
            <div :key="Math.random()">
              <a-upload
                name="file"
                accept=".txt,.doc,.docx,.xls,.xlsx,.ppt,.pptx,.pdf"
                :beforeUpload="beforeUpload"
                :showUploadList="false"
                :multiple="false"
                :headers="tokenHeader"
                :action="importExcelUrl"
                @change="myhandleImportExcel"
              >
                <a-button><a-icon type="upload" />上传</a-button>
              </a-upload>
            </div>
          </a-form-item>
        </a-col>
        <a-col :span="24 / 3">
          <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="备注">
            <a-textarea :rows="2" placeholder="请输入备注" v-decorator.trim="['remark']" />
          </a-form-item>
        </a-col>
        <div>
          <a-divider>产品详情添加</a-divider>
          <a-col :span="24 / 3">
            <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="产品名">
              <a-input placeholder="请输入产品名" v-model="name" />
            </a-form-item>
          </a-col>
          <a-col :span="24 / 3">
            <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="产品单位">
              <a-input placeholder="请输入产品单位" v-model="unit" />
            </a-form-item>
          </a-col>
          <a-col :span="24 / 3">
            <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="数量">
              <!-- <a-input placeholder="请输入数量" v-model="count" /> -->
              <a-input-number style="width:100%;" placeholder="请输入数量" v-model="count" :min="1" />
            </a-form-item>
          </a-col>
          <a-col :span="24">
            <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="规格展示">
              {{
                newMapObject
                  ? newMapObject
                      .split('{')
                      .join('')
                      .split('}')
                      .join('')
                      .split('"')
                      .join('')
                  : '可添加多个'
              }}
              <!-- <a-input placeholder="请输入业务负责人" v-model="specification" /> -->
            </a-form-item>
          </a-col>
          <a-col :span="24 / 3">
            <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="属性">
              <a-input placeholder="请输入" v-model="guiG" />
            </a-form-item>
          </a-col>
          <a-col :span="24 / 3">
            <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="值">
              <a-input placeholder="请输入" v-model="guiGvalue" />
            </a-form-item>
          </a-col>
          <a-col :span="24 / 3" style=" float: right;top:5px">
            <a-button @click="addNewModel()" type="primary">添加规格属性</a-button>
            <a-divider type="vertical" />
            <a-button @click="addList" type="primary">添加至产品详情</a-button>
          </a-col>
          <a-divider>产品详情</a-divider>
        </div>
      </a-form>
    </a-spin>
    <div>
      <a-table ref="table" size="middle" bordered rowKey="id" :columns="columns" :dataSource="dataSource">
        <template
          v-for="col in ['name', 'specification', 'count', 'unit']"
          :slot="col"
          slot-scope="text, record, index"
        >
          <div :key="col">
            <a-input
              v-if="record.editable"
              style="margin: -5px 0"
              :value="text"
              @change="e => myhandleChange(e.target.value, record, col)"
            />
            <template v-else>
              {{ text }}
            </template>
          </div>
        </template>
        <!-- 操作 -->
        <span slot="action" slot-scope="text, record, index">
          <span class="editable-row-operations">
            <span v-if="record.editable">
              <a @click="() => save(record)">保存</a>
            </span>
            <span v-else>
              <a :disabled="editingKey !== ''" @click="() => Listedit(record)">编辑</a>
            </span>
          </span>
          <a-divider type="vertical" />
          <span>
            <a-popconfirm title="确定删除吗?" @confirm="() => Delete(record)">
              <a>删除</a>
            </a-popconfirm>
          </span>
        </span>
      </a-table>
    </div>
  </a-modal>
</template>
<script>
import pick from 'lodash.pick'
import { addContractdetails, checkSupplier, editContractdetails, personList } from '@/api/api'
import { getAction, deleteAction } from '@/api/manage'
import { BillModalMixin } from '@views/bill/mixins/BillModalMixin'
import { autoJumpNextInput } from '@/utils/util'
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import Vue from 'vue'
import { ACCESS_TOKEN } from '@/store/mutation-types'
export default {
  name: 'ContractDetails',
  mixins: [BillModalMixin, JeecgListMixin],
  data() {
    return {
      title: '操作',
      form: this.$form.createForm(this),
      //token header
      tokenHeader: { Authorization: 'Bearer ' + Vue.ls.get(ACCESS_TOKEN) },
      defaultFileList: null,
      visible: false,
      model: {},
      name: '',
      count: '',
      unit: '',
      editingKey: '',
      other: false,
      cacheData: [],
      // 查询条件
      personList: [],
      isReadOnly: false,
      url: {
        lists: '/contractProduct/getProductList',
        importExcelUrl: '/systemConfig/upload' + '?' + `biz=htmx`,
        delete: '/contractProduct/remove'
      },
      dataSource: [],
      columns: [
        { title: '产品名', dataIndex: 'name', width: 80, scopedSlots: { customRender: 'name' } },
        { title: '规格', dataIndex: 'specification', width: 80, scopedSlots: { customRender: 'specification' } },
        { title: '单位', dataIndex: 'unit', width: 80, scopedSlots: { customRender: 'unit' } },
        { title: '数量', dataIndex: 'count', width: 80, scopedSlots: { customRender: 'count' } },
        {
          title: '操作',
          dataIndex: 'action',
          width: 80,
          align: 'center',
          scopedSlots: { customRender: 'action' }
        }
      ],
      bodyStyle: {
        padding: '20',
        height: window.innerHeight * 0.6 + 'px',
        'overflow-y': 'auto'
      },
      labelCol: {
        xs: { span: 24 },
        sm: { span: 6 }
      },
      wrapperCol: {
        xs: { span: 24 },
        sm: { span: 16 }
      },
      tableShow: true,
      money: false,
      percentage: false,
      value: '',
      mode: [{ name: '预计付款金额' }, { name: '预计付款百分比' }],
      isTrue: [
        {
          id: 0,
          name: '未开票'
        },
        {
          id: 1,
          name: '开票'
        },
        {
          id: 2,
          name: '不开票'
        }
      ],
      Progress: [
        { id: 0, name: '进行中' },
        {
          id: 1,
          name: '已完结'
        },
        {
          id: 2,
          name: '呆账坏账'
        }
      ],
      nature: [
        { id: 0, name: '试用合同' },
        {
          id: 1,
          name: '正常订单'
        },
        {
          id: 2,
          name: '售后合同'
        },
        {
          id: 3,
          name: '其他订单'
        }
      ],
      key: 1,
      disable:false,
      show: null,
      confirmLoading: false,
      guiG: null, //规格键名
      guiGvalue: null, //规格值
      newMapObject: null,
      vaArr: [],
      guiArr: [],
      validatorRules: {
        name: {
          rules: [
            { required: true, message: '请输入名称!' },
            { min: 2, max: 30, message: '长度在 2 到 30 个字符', trigger: 'blur' }
          ]
        },
        prductcode: {
          rules: [{ required: true, message: '请输入!' }]
        }
      }
    }
  },
  computed: {
    importExcelUrl: function() {
      return `${window._CONFIG['domianURL']}${this.url.importExcelUrl}`
      // return `api${this.url.importExcelUrl}`
    }
  },
  mounted() {
    this.handleChange()
    this.cacheData = this.dataSource.map(item => ({ ...item }))
    //判断全部还是个人数据
    this.filterData()
    personList().then(res => {
      if (res.code == 200 || res.code == 10000) {
        this.personList = res.data
      } else {
        this.$message.warning(res.message)
      }
    })
  },
  methods: {
    filterData() {
      let a = JSON.parse(sessionStorage.getItem('UserMessage'))
      let useMsg = JSON.parse(sessionStorage.getItem('User'))
      if (a) {
        this.queryParam.businessLeader = useMsg.ename
        this.disable = true
        console.log(this.queryParam.businessLeader, 'this.queryParam.businessLeader')
      } else {
        this.disable = false
      }
    },
    //图片上传前做限制
    beforeUpload(file) {
      return new Promise((resolve, reject) => {
        //文件名后缀
        let hz = file.name.substring(file.name.lastIndexOf('.'))
        let isType = ['.xlsx', '.doc', '.txt', '.docx', '.xls', '.ppt', '.pptx', '.pdf'].includes(hz)
        if (!isType) {
          this.$message.error('格式错误,只能上传.xlsx、.doc、.txt、.docx、.xls、.ppt、.pptx、.pdf')
          return reject(false)
        }
        return resolve(true)
      })
    },
    //合同性质选择
    selectChange(value) {
      if (value == '其他订单') {
        this.other = true
      } else {
        this.other = false
      }
    },
    Listedit(record) {
      const newData = [...this.dataSource]
      if (record.key) {
        var target = newData.find(item => record.key === item.key)
      } else {
        var target = newData.find(item => record.id === item.id)
      }

      this.editingKey = record.key ? record.key : record.id
      if (target) {
        target.editable = true
        this.dataSource = newData
      }
    },
    //
    save(record) {
      const newData = [...this.dataSource]
      if (record.key) {
        var target = newData.find(item => record.key === item.key)
      } else {
        var target = newData.find(item => record.id === item.id)
      }
      this.editingKey = ''
      if (target) {
        Object.assign(
          target,
          record.key
            ? this.cacheData.find(item => record.key === item.key)
            : this.cacheData.find(item => record.id === item.id)
        )
        delete target.editable
        this.dataSource = newData
      }
    },
    myhandleChange(value, record, column) {
      const newData = [...this.dataSource]
      if (record.key) {
        var target = newData.find(item => record.key === item.key)
      } else {
        var target = newData.find(item => record.id === item.id)
      }
      if (target) {
        target[column] = value
        this.dataSource = newData
      }
    },
    /* 导入 */
    myhandleImportExcel(info) {
      if (info.file.status !== 'uploading') {
        console.log(info.file, info.fileList)
      }
      if (info.file.status === 'done') {
        if (info.file.response) {
          // this.$message.success(`${info.file.name} 文件上传成功`);
          if (info.file.response.code === 200 || info.file.response.code === 10000) {
            this.$message.success(`${info.file.name} 文件上传成功` || info.file.response.data)
            this.defaultFileList = info.file.response.data
            console.log('defaultFileList:', this.defaultFileList)
          } else {
            this.$message.warning(info.file.response.message)
          }
        } else {
          this.$message.error(`${info.file.name} ${info.file.response.data}.`)
        }
      } else if (info.file.status === 'error') {
        this.$message.error(`文件上传失败: ${info.file.msg} `)
      }
    },
    //规格键值合并
    addNewModel() {
      this.newMap = new Map()
      if (this.guiG && this.guiGvalue) {
        this.vaArr.push(this.guiGvalue)
        this.guiArr.push(this.guiG)
      }
      for (var i = 0; i < this.vaArr.length; i++) {
        this.newMap.set(this.guiArr[i], this.vaArr[i])
      }
      this.newMapObject = JSON.stringify(this._strMapToObj(this.newMap))
      this.$nextTick(() => {
        this.guiG = null
        this.guiGvalue = null
        this.newMap = null
      })
    },
    //map转化为对象
    _strMapToObj(strMap) {
      let obj = Object.create(null)
      for (let [k, v] of strMap) {
        obj[k] = v
      }
      return obj
    },
    //添加产品List
    addList() {
      if (this.name && this.unit && this.newMapObject && this.count) {
        this.dataSource.push({
          key: this.key,
          name: this.name,
          unit: this.unit,
          specification: this.newMapObject
            ? this.newMapObject
                .split('{')
                .join('')
                .split('}')
                .join('')
                .split('"')
                .join('')
            : this.newMapObject,
          count: this.count
        })
        this.key++
        this.name = null
        this.unit = null
        this.newMapObject = null
        this.count = null
        this.vaArr = []
        this.guiArr = []
      } else {
        return
      }
    },
    //删除产品List
    Delete(record) {
      console.log(record)
      //根据key，id判断删除dom还是接口删除
      if (record.key) {
        console.log('dom删')
        let key = record.key
        const dataSource = [...this.dataSource]
        this.dataSource = dataSource.filter(item => item.key !== key)
      } else if (record.id) {
        deleteAction(this.url.delete, { id: record.id }).then(res => {
          if (res.code === 200 || res.code === 10000) {
            let id = record.id
            const dataSource = [...this.dataSource]
            this.dataSource = dataSource.filter(item => item.id !== id)
            // this.getTableList(record)
          } else {
            that.$message.warning(res.data.message)
          }
        })
      }
    },
    handleChange(value) {
      if (value) {
        this.value = value
      } else {
        this.value = this.mode[0].name
      }

      if (value == '预计付款金额') {
        this.money = true
        this.percentage = false
      } else {
        this.percentage = true
        this.money = false
      }
    },
    getTableList(record) {
      this.loading = true
      let params = {}
      //规格属性管理查询条件
      params.contractCode = record.contractCode
      //页码字段未统一
      params.current = this.ipagination.current
      params.currentPage = this.ipagination.current
      params.size = this.ipagination.pageSize
      params.pageSize = this.ipagination.pageSize
      getAction(this.url.lists, params).then(res => {
        if (res.code === 200 || res.code === 10000) {
          if (res.data.records && res.data.records.length > 0) {
            this.dataSource = res.data.records
          }
        }
      })
      this.loading = false
    },
    add() {
      this.edit()
    },
    edit(record) {
      let isShow = JSON.parse(sessionStorage.getItem('UserMessage'))
      this.show = isShow
      this.form.resetFields()
      this.model = Object.assign({}, record)
      this.visible = true
      this.defaultFileList = this.model.contractPdf
      this.tableShow = true
      if (this.model.contractType == '其他订单') {
        this.other = true
      } else {
        this.other = false
      }
      this.$nextTick(() => {
        setTimeout(() => {
          let aaa = JSON.parse(sessionStorage.getItem('UserMessage'))
          if (aaa) {
            let a = JSON.parse(sessionStorage.getItem('User'))
            this.form.setFieldsValue({ businessLeader: a.ename })
          }
          //如果有record则走编辑,日期回显
          if (record) {
            this.money = true
            this.percentage = true
            this.tableShow = false
            var earlyWarningDate = this.$moment(this.model.earlyWarningDate)
            this.form.setFieldsValue({ earlyWarningDate: earlyWarningDate })
            var signedDate = this.$moment(this.model.signedDate)
            this.form.setFieldsValue({ signedDate: signedDate })
            //编辑页面调用接口回显
            this.getTableList(record)
          } else {
            this.dataSource = []
          }
          this.form.setFieldsValue(
            pick(
              this.model,
              'area',
              'industry',
              'businessLeader',
              'contractAmount',
              'contractCode',
              'contractNum',
              'contractSchedule',
              'contractType',
              'earlyWarningAmount',
              'preciousMetal',
              'earlyWarningRate',
              'contractSecondType',
              // 'invoicedAmount',
              // 'isInvoiced',
              // 'name',
              // 'receivedAmount',
              'setOfOrders',
              // 'specification',
              'termOfPayment',
              'remark',
              'customerName'
            )
          )
          autoJumpNextInput('customerModal')
        }, 400)
      })
    },
    close() {
      this.$emit('close')
      this.visible = false
    },
    handleOk() {
      const that = this
      // 触发表单验证
      this.form.validateFields((err, values) => {
        if (!err) {
          that.confirmLoading = true
          let formData = Object.assign(this.model, values)
          if (this.model.beginNeedGet && this.model.beginNeedPay) {
            that.$message.warn('期初应收和期初应付不能同时输入')
            that.confirmLoading = false
            return
          }
          formData.contractProductList = this.dataSource
          console.log(formData.contractProductList.length == 0, 'console.log(formData.contractProductList);')
          console.log(formData.contractProductList.length, 'console.log(formData.contractProductList);')
          if (formData.contractProductList.length == 0) {
            this.$message.warning('请添加产品详情!')
            that.confirmLoading = false
            return
          } else {
            formData.contractPdf = this.defaultFileList
            formData.earlyWarningDate = this.$moment(formData.earlyWarningDate).format('YYYY-MM-DD')
            formData.signedDate = this.$moment(formData.signedDate).format('YYYY-MM-DD')
            if (this.value == '预计付款金额') {
              formData.earlyWarningRate = (formData.earlyWarningAmount / formData.contractAmount) * 100 //算百分比
            } else {
              formData.earlyWarningAmount = (formData.earlyWarningRate / 100) * formData.contractAmount //算金额
            }
            console.log(formData)
            let obj
            if (!this.model.id) {
              obj = addContractdetails(formData)
            } else {
              obj = editContractdetails(formData)
            }
            obj
              .then(res => {
                if (res.code === 200 || res.code === 10000) {
                  this.$message.success('保存成功')
                  that.$emit('ok')
                } else {
                  that.$message.warning(res.message)
                }
              })
              .finally(() => {
                that.confirmLoading = false
                that.dataSource = []
                that.close()
              })
          }
        }
      })
    },
    handleCancel() {
      this.close()
    },
    validateSupplierName(rule, value, callback) {
      let params = {
        name: value,
        type: '客户',
        id: this.model.id ? this.model.id : 0
      }
      checkSupplier(params).then(res => {
        if (res && res.code === 200) {
          if (!res.data.status) {
            callback()
          } else {
            callback('名称已经存在')
          }
        } else {
          callback(res.data)
        }
      })
    }
  }
}
</script>
<style scoped>
#billModal {
  margin: 20px 0;
}
.editable-row-operations a {
  margin-right: 8px;
}
@import '~@assets/less/common.less';
</style>
